import { Entity, Column, PrimaryGeneratedColumn, ManyToOne, OneToMany } from 'typeorm';
import { ApiProperty } from '@nestjs/swagger';
import { School } from 'src/modules/school/entities/school.entity';
import { BaseEntity } from 'src/common/entities/entities';
import { User } from 'src/modules/user/entities/user.entity';

@Entity({ name: 'major' })
export class Major extends BaseEntity {
  @ApiProperty({ example: 1, description: '专业ID' })
  @PrimaryGeneratedColumn()
  id: number;

  @ApiProperty({ example: '计算机科学与技术', description: '专业名称' })
  @Column()
  name: string;

  // @ManyToOne(() => School, school => school.majors)
  // school: School;

  /** 专业学生 */
  @ApiProperty({ example: '专业学生', description: '专业学生列表' })
  @OneToMany(() => User, user => user.major)
  users: User[];
}
